<?php
class appModelAdmin extends coreFrameworkModel 
{
	
	function __construct()
	{
		parent::__construct();
	}
	//获取应用列表
	function getAppList(){
		$join = ' left join '.SqlToolsClass::getTableName('dl_resources').' r on r.id = c.resources_id'.' left join '.SqlToolsClass::getTableName('dl_channelsite').' cs on cs.id=c.channelsite_id';
		$sql=SqlToolsClass::SelectItem("dl_channel as c","","*,c.c_time,c.id,c.channel_name,cs.channel_name as channelsite_name",$join);
		return $this->GetAll($sql);
	}
	//获取资源方列表
	function getResourcesList(){
		
		$sql=SqlToolsClass::SelectItem("dl_resources",'','*',null,'id desc');
		//return $this->GetAll($sql);
		return $this->createPage($sql);
	}

	//保存应用
	function saveApp($data,$id){
		if ($id) {
			$sql = SqlToolsClass::EditData('dl_channel',$data,'id='.$id);			
		}else{
			$sql = SqlToolsClass::InsertData('dl_channel',$data);
		
		}
		return $this->Execute($sql);
	}
	
	function getChannerData($id){
		$sql = SqlToolsClass::SelectItem('dl_channel','id='.$id);
		return $this->GetRow($sql);
	}
	function getChannelLog($where){
		
		
		$sql = SqlToolsClass::SelectItem('dl_channel_log',$where);
		return $this->GetAll($sql);
	}
	//获取日志按照条件分组
	function getChannelLogGroupBy($where,$group){
		
		
		$sql = SqlToolsClass::SelectItem('dl_channel_log',$where,'*,count(*) as num',"","",$group);
		return $this->GetAll($sql);
	}
	

	//保存资源方信息
	function saveResources($data){
		$sql=SqlToolsClass::InsertData("dl_resources", $data);
		return $this->Execute($sql);
	}
	//查询资源方信息
	function getResources($id){
		$sql=SqlToolsClass::SelectItem("dl_resources","id=$id");
		return $this->GetRow($sql);
	}
	//删除资源方信息
	function delResources($id){
		$sql=SqlToolsClass::DeleteData("dl_resources","id=$id");
		return $this->GetRow($sql);
	}
	//编辑资源信息
	function editResources($data,$id)
	{
		$sql=SqlToolsClass::EditData("dl_resources",$data,"id=$id");
		return $this->GetRow($sql);
	}
	//获取渠道方列表
	function getChannelList()
	{
		$sql=SqlToolsClass::SelectItem("dl_channelsite",'','*',null,'id desc');
		//return $this->GetAll($sql);
		return $this->createPage($sql);
	}
	//获取渠道方列表
	function getChannelListTwo()
	{
		$sql=SqlToolsClass::SelectItem("dl_channelsite",'','*',null,'id desc');
		return $this->GetAll($sql);
	}
	//保存渠道方信息
	function saveChannel($data){
		$sql=SqlToolsClass::InsertData("dl_channelsite", $data);
		return $this->Execute($sql);
	}
	//查询渠道方信息
	function getChannel($id){
		$sql=SqlToolsClass::SelectItem("dl_channelsite","id=$id");
		return $this->GetRow($sql);
	}
	//编辑渠道方信息
	function editChannel($data,$id)
	{
		$sql=SqlToolsClass::EditData("dl_channelsite",$data,"id=$id");
		return $this->GetRow($sql);
	}
	//删除渠道方信息
	function delChannel($id){
		$sql=SqlToolsClass::DeleteData("dl_channelsite","id=$id");
		return $this->GetRow($sql);
	}
}


?>